﻿#include "friend.h"
#include "ui_friend.h"
#include "protocol.h"
#include "utils.h"
#include <QInputDialog>

Friend::Friend(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Friend)
{
    ui->setupUi(this);
}

Friend::~Friend()
{
    delete ui;
}

void Friend::on_pbn_SearchUsr_clicked()
{
    bool ok;
    m_strSearchName = QInputDialog::getText(this,"搜索","用户名", QLineEdit::Normal, "", &ok, (Qt::WindowCloseButtonHint|Qt::MSWindowsFixedSizeDialogHint));
    if(!m_strSearchName.isEmpty())
    {
        MYLOG << "待查找的用户名为：" << m_strSearchName;
        PDU *pdu = mkPDU(0);
        strcpy_s(pdu->caData, m_strSearchName.toStdString().c_str());
        pdu->uiMsgType = ENUM_MSG_TYPE_SEARCH_USER_REQUEST;
        m_tcpSocket->write((char*)pdu,pdu->uiPDULen);
        free(pdu);
        pdu = NULL;
    }
}

